/**
 * Created by linghong on 2018/12/24.
 */
//返回上一页
//logUser.html
function go() {
	window.history.go(-1);
}

var Url = "http://192.168.0.126:8080";

//封装ajax
function Hajax(type, site, parameter, callback) {

	$.ajax({
		type: type,
		url: Url + site,
		xhrFields: {
			withCredentials: true
		},
		data: parameter,
		success: ((data) => {
			console.log(data);
			console.log(data.success);
			if(data.success == undefined) {
				callback(data);
			} else if(data.success) {
				callback(data);
			} else {
				popup(data.message);
			}

		}),
		error: ((err) => {
			console.log(err);
		})

	});
}

//验证码倒计时
var count = (classSum) => {
	classSum.val("60");
	console.log(classSum);
	var second = 60;
	var timer = setInterval(function() {
		second -= 1;
		if(second > 0) {
			classSum.val(second);
			classSum.attr('disabled', "true");
		} else {
			classSum.val("获取验证码");
			classSum.removeAttr("disabled"); //将按钮禁用
			clearInterval(timer);
		}
	}, 1000);
}

//正则 
//判断密码，手机号等
function vali(elem, reg, errMsg) {
	elem = $(elem);
	if(elem.val() == null || elem.val() == "" || !reg.test(elem.val())) {
		//将问题显示在页面上
		//			Upop(errMsg);	
		//			console.log(errMsg);
		popup(errMsg);
		return false;
	} else if(reg.test(elem.val())) { //如果验证通过		
		//			console.log("正确");
		return true;
	}
}

//弹窗
var popup = ((Text) => {
	$("body").append('<div class="tishi">' + Text + '<div><button class="popup-button">确定</button></div></div>');
	$(".tishi").css({
		"width": "5rem",
		"position": "fixed",
		"font-size": "0.24rem",
		"background": "#ffffff",
		"color": "#333333",
		"box-shadow": "1px 1px 20px #333333",
		"height": "2.5rem",
		"top": "26vh",
		"left": "18vw",
		"border-radius": "32px",
		"text-align": "center",
		"padding-top": ".7rem",
		"z-index": "999"
	});

	$(".popup-button").css({
		"width": "3rem",
		"height": ".5rem",
		"margin-top": ".5rem",
		"font-size": "0.24rem",
		"background": "#4483f4",
		"color": "#ffffff",
	})

	setTimeout(function() {
		first = null;
		$(".tishi").fadeOut(3000, function() {
			//		            	$(".tishi").remove();
		});
	}, 1000);

	$(".popup-button").click(() => {
		$(".tishi").remove();
	})

})

//如何获取地址栏后面的信息
function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return unescape(r[2]);
	return null;
}

function UrlSearch() {
	var name, value;
	var str = location.href; //取得整个地址栏
	var num = str.indexOf("?")
	str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]

	var arr = str.split("&"); //各个参数放到数组里
	for(var i = 0; i < arr.length; i++) {
		num = arr[i].indexOf("=");
		if(num > 0) {
			name = arr[i].substring(0, num);
			value = arr[i].substr(num + 1);
			this[name] = value;
		}
	}
}
// UrlSearch函数的调用方法
//var Request=new UrlSearch(); //实例化
//alert(Request.id);
//decodeURI("");  返回的如果是汉字的话，需要放到这里面转码






//io.dcloud.H5D295A61                  包名
//fb9a78d54ea8cd6ca4cc66abf373eafb    安装包签名


//微信的
//APPID  : wx0d425fc8565b81ba
//AppSecret ：fa7d1dab1233a691e8a5a62170caa30c


//qq的
//APPID  : 101540239
//AppSecret ： 5b1d01b6e14dda7c4ffce7757c110a13
